﻿using System;
using System.Collections.Generic;
using System.Text;
using HyEduOnline.Entities;
using HyEduOnline.Data;


namespace HyEduOnline.Web
{
	
	
	
			//Item.Id			////描述:,数据类型:Int32
		//Item.SSenderNo			////描述:,数据类型:AnsiString
		//Item.SSenderName			////描述:,数据类型:AnsiString
		//Item.SRecNameList			////描述:,数据类型:AnsiString
		//Item.STitle			////描述:,数据类型:AnsiString
		//Item.DSendtime			////描述:,数据类型:DateTime
		//Item.IEmailType			////描述:,数据类型:Int32
		//Item.IIsDestroyAffterRead			////描述:,数据类型:Int32
		//Item.IIsCancel			////描述:,数据类型:Int32
		//Item.SSendIp			////描述:,数据类型:AnsiString
		//Item.IIsDeleteFlag			////描述:,数据类型:Int32
		//Item.SRecNo			////描述:,数据类型:AnsiString
		//Item.SRecName			////描述:,数据类型:AnsiString
		//Item.IIsRead			////描述:,数据类型:Int32
		//Item.IIsExistAttchment			////描述:,数据类型:Int32
//---Begin-开始生成Ext Grid的模板 
//<asp:ObjectDataSource ID="odsEmail" runat="server" SelectMethod="GetByPageVW" 
//	TypeName="HyEduOnline.Web.Email" OnSelected="odsEmail_Selected" DeleteMethod="Del" UpdateMethod="Update"> 
// <SelectParameters> 
//<asp:SessionParameter Name="whereClause" SessionField="whereClause" Type="String" /> 
//<asp:Parameter Name="start" Type="Int32" /> 
//<asp:Parameter Name="limit" Type="Int32" /> 
//<asp:Parameter Name="sort" Type="String" /> 
//<asp:Parameter Name="dir" Type="String" /> 
//<asp:Parameter Name="count" Direction="Output" Type="Int32" /> 
// </SelectParameters> 
//<DeleteParameters> 
//<asp:Parameter Name="id" Type="Int32" /> 
//</DeleteParameters> 
//</asp:ObjectDataSource> 
//<ext:Store ID="storeEmail" runat="server" AutoLoad="true" RemoteSort="true" DataSourceID="odsEmail" OnRefreshData="storeEmail_RefreshData" EnableViewState="false"> 
//<AutoLoadParams> 
//<ext:Parameter Name="start" Value="={0}" /> 
//<ext:Parameter Name="limit" Value="={10}" /> 
//</AutoLoadParams> 
//<Proxy> 
//<ext:DataSourceProxy /> 
//</Proxy> 
//<Reader> 
//<ext:JsonReader > 
//<Fields> 
		//<ext:RecordField Name="Id" />  
		//<ext:RecordField Name="SSenderNo" />  
		//<ext:RecordField Name="SSenderName" />  
		//<ext:RecordField Name="SRecNameList" />  
		//<ext:RecordField Name="STitle" />  
		//<ext:RecordField Name="DSendtime" />  
		//<ext:RecordField Name="IEmailType" />  
		//<ext:RecordField Name="IIsDestroyAffterRead" />  
		//<ext:RecordField Name="IIsCancel" />  
		//<ext:RecordField Name="SSendIp" />  
		//<ext:RecordField Name="IIsDeleteFlag" />  
		//<ext:RecordField Name="SRecNo" />  
		//<ext:RecordField Name="SRecName" />  
		//<ext:RecordField Name="IIsRead" />  
		//<ext:RecordField Name="IIsExistAttchment" />  
//</Fields> 
//</ext:JsonReader> 
//</Reader> 
//  <SortInfo Field="Id" Direction="DESC" />//</ext:Store> 
//<ext:GridPanel runat="server" ID="gpEmail" Title="Email" Frame="true" StoreID="storeEmail"  Height="300" AutoExpandColumn="Id" EnableViewState="false" TitleCollapse="false" > 
//<TopBar>			
//<ext:Toolbar runat="server" ID="EmailTools">			
//<Items>			
//<ext:ToolbarButton ID="btnEmailAdd" runat="server" Text="新增记录" Icon="add">			
//	<Listeners>		
//	<Click Handler="AddEmail();" />		
//	</Listeners>		
//</ext:ToolbarButton>
// <ext:ToolbarButton ID="btnEmailEdit" runat="server" Text="编辑记录" Icon="bulletedit" Disabled="true">			
//	<Listeners>		
//	<Click Handler="EditEmail(#{gpEmail});" />		
//	</Listeners>		
// </ext:ToolbarButton>			
//	<ext:ToolbarFill runat="server" />		
//	 <ext:ToolbarButton ID="btnEmailDelete" runat="server" Text="删除记录" AutoPostBack="false"   Icon="Delete" Disabled="true">		
//	<Listeners>		
//	<Click Handler="if(confirm('真的要删除此记录吗？')){		
//	#{gpEmail}.deleteSelected();		
//	if (!#{gpEmail}.hasSelection()) {#{btnEmailDelete}.disable();};		
//	#{gpEmail}.save();		
//	return true;}		
//	else{return false;}" />		
//	</Listeners>		
//	</ext:ToolbarButton>		
//	</Items>		
//	</ext:Toolbar>		
//	</TopBar>		
// <columnmodel id="ColumnModel1" runat="server"> 
// <Columns> 
//<ext:Column  Header="" Width="50"  DataIndex="Id"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SSenderNo"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SSenderName"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SRecNameList"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="STitle"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="DSendtime"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IEmailType"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IIsDestroyAffterRead"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IIsCancel"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SSendIp"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IIsDeleteFlag"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SRecNo"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="SRecName"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IIsRead"  />	  
//<ext:Column  Header="" Width="50"  DataIndex="IIsExistAttchment"  />	  
// </Columns> 
//</columnmodel> 
//	<LoadMask ShowMask="true" Msg="装入..." />		
//	<SaveMask ShowMask="true"  Msg="保存..." />		
//<selectionmodel> 
//	<ext:CheckboxSelectionModel>		
//	 <Listeners>		
//	<RowSelect Handler="#{btnEmailDelete}.enable();#{btnEmailEdit}.enable();" />		
//	<RowDeselect Handler="if (!#{gpEmail}.hasSelection()) {#{btnEmailDelete}.disable();#{btnEmailEdit}.disable();}" />		
//	</Listeners>			
//	 </ext:CheckboxSelectionModel>			
//</selectionmodel> 
//<bottombar> 
// <ext:PagingToolBar ID="pbEmail" runat="server" PageSize="10" StoreID="storeEmail"   DisplayInfo="true" DisplayMsg="第{0}- {1}  共{2}条 " EmptyMsg="没有找到数据!" /> 
//</bottombar> 
//<loadmask showmask="true" /> 
//</ext:GridPanel> 
// <script type="text/javascript">    
//  function EditEmail(gv){   
//     var selection = gv.getSelectionModel().getSelections();
//     if(selection[0])alert(selection[0].id);
//     else Ext.Msg.alert('出错提示','您需要选择一个记录，如果选择是多记录,则自动选择中第一记录!);
//    } 
//    </script> 
//     
//     
//     
//     
//     
//     
//     

	
	/// <summary>
	///		此用于处理视图对象 'vw_Email' 
	/// </summary>
	/// <remarks>
	/// 	此结构由代码由TMS代码生成器书写生成，请不要直接修改.
	///注意:此代码可能和同名的表生成一个完整对象
	/// </remarks>
    public partial class VwEmailBaseDAO 
	{
	
	#region 视图代码
		
		protected int VWTotalCount = -1;
		
		
		/// <summary>
        /// 取所有的对象,例如VList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  VList<VwEmail> GetVWAll()
        {
            return DataRepository.Provider.VwEmailProvider.GetAll();
        }


        /// <summary>
        /// 条件查询分页
        /// </summary>
        /// <param name="whereClause">条件</param>
        /// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  VList<VwEmail> GetByPageVW(string whereClause, int startRowIndex, int maximumRows)
        {
			
			
            return DataRepository.Provider.VwEmailProvider.Get(whereClause, "ID", (int)startRowIndex/maximumRows , maximumRows, out VWTotalCount);

        }
		/// <summary>
		///支持Ext的分页查询,视图
		/// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>VList<???></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public VList<VwEmail> GetByPageVW(string whereClause, int start, int limit, string sort, out int count)
        {
            string dir = "DESC";  //设置默认的排序方式为降序
            string sOrder = "";
            string[] sor = sort.Split(' ');
            sort = sor[0];
            sOrder = sor[1];
            if (sort != null && sort.ToUpper() != "ID")
            {
                sOrder = sort.Insert(1, "_") + " " + dir;
            }
            else
            {
                if (sort.ToUpper() == "ID") sOrder = sort + " " + dir;
            }
            return DataRepository.Provider.VwEmailProvider.Get(whereClause, sOrder, (int)start / limit, limit, out count);
        }

        /// <summary>
        /// 分页查询计数
        /// </summary>
        /// <param name="whereClause"></param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public int GetVWCount(string whereClause, int startRowIndex, int maximumRows)
        {
            if (VWTotalCount != -1)
            {
                return VWTotalCount;
            }
            else
            {
                DataRepository.Provider.VwEmailProvider.GetTotalItems(whereClause, out VWTotalCount);
                return VWTotalCount;
            }
        }
		
		/// <summary>
        /// 更具条件查找
        /// </summary>
        /// <param name="whereClause">需要查找的条件</param>
        /// <returns>VList对象</returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public VList<VwEmail> GetVWByCondition(string whereClause)
		{
			return GetByPageVW(whereClause,0,int.MaxValue);
		}
		

        /// <summary>
        /// 通过id来取对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public VwEmail GetByVWID(int id)
        {
			
			 VwEmail  Item = null;

            VList<VwEmail> vwList = GetByPageVW("ID=" + id.ToString(), 0, 1);
            if (vwList.Count > 0)
            {
                Item = vwList[0];
            }
            return Item;
            
        }




		#endregion 视图代码







	}
}